package com.nan.operation;

import com.nan.book.Book;
import com.nan.book.BookList;

import java.util.Scanner;

//查找图书
public class FindOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("查找图书");
        System.out.println("请输入查找书的名称：");
        Scanner scanner=new Scanner(System.in);
        String name= scanner.next();
        for(int i=0;i< bookList.getUsedSize();i++){//遍历存放书的那个数组
            Book book=bookList.getBook(i);//表示获取i位置是哪本书,用book接收这本书
            //再获取这本书的名字用book.getName()
            if(book.getName().equals(name)){
                System.out.println("查找到了这本书");
                System.out.println(book);
                return;
            }
        }
        System.out.println("没有此书籍！");
    }
}
